package com.sleep.satokendemo.controller;

import cn.hutool.json.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.sleep.satokendemo.dto.MessageDto;
import com.sleep.satokendemo.listener.RedisListener;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author GuoAo
 * @className RstreamController
 * @date 2025/7/1
 * @description TODO
 */
@RequestMapping("/stream")
@RequiredArgsConstructor
@RestController
public class RstreamController {

    private final RedisListener redisListener;

    @PostMapping("/push")
    public String push(@RequestBody MessageDto  message) {
        redisListener.push(JSON.toJSONString( message));
        return "success";
    }
}
